home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / CPP / ACGIFREE.ZIP / INCLUDE / A_PREDEF.H < prev    next >
Encoding:
C/C++ Source or Header  |  1996-09-10  |  8.0 KB  |  227 lines

  1. //a_predef.h
  2.  
  3. #pragma message( "Including " __FILE__ )
  4.  
  5. #ifndef __A_PREDEF_H__
  6. #define __A_PREDEF_H__
  7.  
  8. #include <iostream.h>
  9.  
  10. #if defined(_MSC_VER) || defined(__BORLANDC__)
  11. #include <strstrea.h>     //a_Visual C++ and Borland C++ use the 8.3 filenames
  12. #else
  13. #include <strstream.h>    //a_This one is for long filename systems like UNIX
  14. #endif
  15.  
  16. //a_These are defines to be used from the Standard C/C++ Runtime library
  17. #include <fstream.h>
  18. #include <assert.h>
  19. #include <stdlib.h>
  20. #include <string.h>
  21. #include <ctype.h>
  22. #include <time.h>
  23. #include <limits.h>
  24. #include <float.h>
  25. #include <math.h>
  26.  
  27. //a_The NULL string, useful for runtime functions that can't handle NULL pointers
  28. //a_iostream's are an example of this, as are string/memory manipulation routines
  29. #define NULL_STRING "(null)"
  30. #define SAFESTRING(pcc) (pcc ? pcc : NULL_STRING)
  31.  
  32. //a_min/max functions
  33. //a_Min/Max support for UNIX :)
  34. #ifndef __min
  35. #define __min(A,B) ((A) > (B) ? (B) : (A))
  36. #endif
  37. #ifndef __max
  38. #define __max(A,B) ((A) > (B) ? (A) : (B))
  39. #endif
  40.  
  41. //a_Unsigned fixed types, 1 byte, 2 bytes, and 4 bytes, and machine specific unsigned int
  42. typedef unsigned char BYTE;
  43. typedef unsigned short WORD;
  44. typedef unsigned long DWORD;
  45. typedef unsigned int UINT;
  46.  
  47. //a_Access MACROs for the unsigned types
  48. #define MAKEWORD(hi, lo)    ((WORD)(((BYTE)(lo)) | ((WORD)((BYTE)(hi))) << 0x8))
  49. #define MAKEDWORD(hi, lo)   ((DWORD)(((WORD)(lo)) | ((DWORD)((WORD)(hi))) << 0xF))
  50.  
  51. #define LOWORD(dw)          ((WORD)(dw))
  52. #define HIWORD(dw)          ((WORD)(((DWORD)(dw) >> 0x10) & 0xFFFF))
  53. #define LOBYTE(w)           ((BYTE)(w))
  54. #define HIBYTE(w)           ((BYTE)(((WORD)(w) >> 0x8) & 0xFF))
  55.  
  56. #define BYTE0(dw)           ((BYTE)(dw))
  57. #define BYTE1(dw)           ((BYTE)(((WORD)(dw)  >> 0x8)  & 0xFF))
  58. #define BYTE2(dw)           ((BYTE)(((DWORD)(dw) >> 0x10)  & 0xFF))
  59. #define BYTE3(dw)           ((BYTE)(((DWORD)(dw) >> 0x18) & 0xFF))
  60.  
  61. #define BITMASK(n)          (0x1L << (n))
  62. #define WIDTHMASK(n)        ((((0x1L << ((n) - 0x1)) - 0x1L) << 0x1) | 0x1L)
  63.  
  64. //a_Ceiling MACRO in multiple on N
  65. #define CEILN(num, N)       (((num + N - 1) / N) * N)
  66. #define FLOORN(num, N)      ((num / N) * N)
  67.  
  68. //a_BLITting constants
  69. #define BLIT_COPY 0x0
  70. #define BLIT_AND  0x1
  71. #define BLIT_OR   0x2
  72. #define BLIT_XOR  0x3
  73.  
  74. //a_COLORREF, used for color definitions
  75. typedef unsigned long COLORREF;          //a_0x00bbggrr
  76.  
  77. //a_RGB
  78. #define RGB(r,g,b)          ((COLORREF)(((BYTE)(r)|((WORD)((BYTE)(g))<<8))|(((DWORD)(BYTE)(b))<<16)))
  79. #define GetRValue(rgb)      ((BYTE)(rgb))
  80. #define GetGValue(rgb)      ((BYTE)(((WORD)(rgb)) >> 8))
  81. #define GetBValue(rgb)      ((BYTE)((rgb)>>16))
  82. //a_Value(brightness) of the COLORREF
  83. #define GetVValue(rgb)      ((BYTE)(max(((BYTE)(rgb)),max(((BYTE)(((WORD)(rgb)) >> 8)),((BYTE)((rgb)>>16))))))
  84. //a_Anti-Value(dullness) of the COLORREF
  85. #define GetLValue(rgb)      ((BYTE)(min(((BYTE)(rgb)),min(((BYTE)(((WORD)(rgb)) >> 8)),((BYTE)((rgb)>>16))))))
  86.  
  87. //a_Quick COLORREF values D(ark) M(edium) L(ight)
  88. #define RGB_BLACK    0x00000000
  89. #define RGB_WHITE    0x00FEFEFE
  90.  
  91. #define RGB_DGRAY    0x00666666
  92. #define RGB_MGRAY    0x008C8C8C
  93. #define RGB_LGRAY    0x00D9D9D9
  94.  
  95. #define RGB_DRED     0x00000066
  96. #define RGB_MRED     0x0000008C
  97. #define RGB_LRED     0x000000D9
  98.  
  99. #define RGB_DGREEN   0x00006600
  100. #define RGB_MGREEN   0x00008C00
  101. #define RGB_LGREEN   0x0000D900
  102.  
  103. #define RGB_DBLUE    0x00660000
  104. #define RGB_MBLUE    0x008C0000
  105. #define RGB_LBLUE    0x00D90000
  106.  
  107. #define RGB_DCYAN    0x00666600
  108. #define RGB_MCYAN    0x008C8C00
  109. #define RGB_LCYAN    0x00D9D900
  110.  
  111. #define RGB_DMAGENTA 0x00660066
  112. #define RGB_MMAGENTA 0x008C008C
  113. #define RGB_LMAGENTA 0x00D900D9
  114.  
  115. #define RGB_DYELLOW  0x00006666
  116. #define RGB_MYELLOW  0x00008C8C
  117. #define RGB_LYELLOW  0x0000D9D9
  118.  
  119. #ifdef _MSC_VER
  120.   //a_Disable Microsoft C based warning so they don't annoy me at level 4 output :)
  121.   //a_4244 - conversion from 'int' to 'char', possible loss of data
  122.   //a_4706 - assignment within conditional expression (I like to do that :)
  123.   #pragma warning( disable : 4244 4706 )
  124. #endif
  125.  
  126. #if defined(__BORLANDC__)
  127.   //a_No warning bothers me in Borland yet :)
  128. #endif
  129.  
  130. //a_RTTI based defines.... Strongly recommend you use RTTI to use all the provided classes
  131. //a__CPPRTTI for VC++ and BC++ enables it by default
  132. #if defined(_CPPRTTI) || defined(__BORLANDC__)
  133. #define __RTTI__ 0x1
  134. #define RTTI_VIRTUAL virtual                                               //a_Use virtual multiple inheritance
  135. #define CAST(vtype, vclass)         (dynamic_cast<vtype>(vclass))          //a_Dynamic RTTI casting
  136. #define ASSERT_CLASS(vtype, vclass) (assert(dynamic_cast<vtype>(vclass)))  //a_If vclass is a reference then bad_cast will be thrown!
  137. #pragma message("a_predef: Using RTTI")
  138. #else
  139. #define RTTI_VIRTUAL                                                       //a_Just define, nothing else
  140. #define CAST(vtype, vclass)         ((vtype)vclass)                        //a_Basic C cast
  141. #define ASSERT_CLASS(vtype, vclass) ((void *)NULL)                         //a_Do nothing but cast (may not work correctly for some multiple inheritance cases)...
  142. #pragma message("a_predef: NOT using RTTI, some classes can't be used without it!")
  143. #endif
  144.  
  145. //a_Alignment constants
  146. #define HALIGN_LEFT   0x1
  147. #define HALIGN_CENTER 0x2
  148. #define HALIGN_RIGHT  0x4
  149.  
  150. //a_FORM Input types
  151. #define FORMINPUT_HIDDEN   0x00
  152. #define FORMINPUT_CHECKBOX 0x01
  153. #define FORMINPUT_RADIO    0x02
  154. #define FORMINPUT_TEXT     0x03
  155. #define FORMINPUT_PASSWORD 0x04
  156. #define FORMINPUT_RANGE    0x05
  157. #define FORMINPUT_SUBMIT   0x06
  158. #define FORMINPUT_RESET    0x07
  159. #define FORMINPUT_TEXTAREA 0x08
  160. #define FORMINPUT_IMAGE    0x09
  161. #define FORMINPUT_SCRIBBLE 0x0A
  162. #define FORMINPUT_FILE     0x0B
  163.  
  164. //a_Maximum buffer for reading TEXTAREA input
  165. //a_Buffer used to process the stream (will contain the Name and Value elements)
  166. //a_<textarea> item may contain a decent amount of Value, so adjust accordingly
  167. #define FL_MAX_INPUT_BUFFER 16384
  168.  
  169. //a_CRC, checksums, etc.. in AConverto
  170. //a_Provided different methods for added security
  171. #define DP_XOR8      0x0001
  172. #define DP_XOR16     0x0002
  173. #define DP_XOR32     0x0003
  174. #define DP_MOD8SUM   0x0010
  175. #define DP_MOD16SUM  0x0011
  176. #define DP_MOD32SUM  0x0012
  177.  
  178. //a_Defines used an NAMEs in AElementList
  179. #define URL_PROTOCOL          "UPROT"
  180. #define URL_NAME              "UNAME"
  181. #define URL_HOST              "UHOST"
  182. #define URL_PORT              "UPORT"
  183. #define URL_PATH              "UPATH"
  184. #define URL_PARAM             "UPARM"
  185.  
  186. //a_Defaults to use
  187. #define URL_PROTOCOL_DEFAULT  "http"
  188. #define URL_PATH_DEFAULT      "/"
  189.  
  190. //a_This is the URL format that I used here
  191. //URL_PROTOCOL://URL_NAME:URL_PASSWORD@URL_HOST:URL_PORT/URL_PATH{?#}URL_PARAM = {?QUERY || #REF}
  192. //
  193. //a_Parsing method:
  194. //1. Reverse parse to find '?' and to the right is URL_QUERY or '#' for URL_REF, remove
  195. //2. Reverse find the first '/', this is URL_FILE.URL_EXTENSION, extract UEXT and remove
  196. //3. Reverse find "//" or start, that is the URL_HOST:URL_PORT/URL_PATH, split and remove
  197. //4. Get the URL_PROTOCOL or use "http:" as a default
  198.  
  199. //a_ID of the protocol used (returned by IsValidProtocol member)
  200. #define URL_ID_BAD    0x0
  201. #define URL_ID_HTTP   0x1
  202. #define URL_ID_FTP    0x2
  203. #define URL_ID_FILE   0x3
  204. #define URL_ID_GOPHER 0x4
  205. #define URL_ID_MAILTO 0x5
  206. #define URL_ID_NEWS   0x6
  207. #define URL_ID_TELNET 0x7
  208. #define URL_ID_TN3270 0x8
  209. #define URL_ID_RLOGIN 0x9
  210. #define URL_ID_WAIS   0xA
  211.  
  212. //a_Output format NAME="VALUE" in APairItem (most common behavior)
  213. #define PI_QUOTED      0x1
  214. //a_Output in APaitItem for {VALUE} will be URL Encoded before outputting
  215. #define PI_URLENCODED  0x2
  216.  
  217. //a_Used for character sets
  218. #define CSM_DEFAULT_LINEHEIGHT 32     //a_Since the sets are all 32x32, this is default
  219. #define CSM_DEFAULT_BASELINE   13     //a_In a 32x32, it's a good baseline, allowing enough above and below, since few are 31 bits high...
  220.  
  221. //a_Shopping Cart related
  222. #define ASC_SEPARATOR '.'             //a_Used to separate {CartName}{Quantity}
  223.  
  224.  
  225. #endif // __A_PREDEF_H__
  226.  
  227.